package com.intellif.oom;

import java.util.ArrayList;

/**
 * @author by mozping
 * @Classname MetaSpaceOOM
 * @Description TODO
 * @Date 2019/8/13 15:33
 */
public class MetaSpaceOOM {

    public static void main(String[] args) {
//        try {
//            //准备url
//            URL url = new File("E:/gitee/total-learn/mozping-jvm/src/main/java/com/intellif/mozping/oom").toURI().toURL();
//
//            URL[] urls = {url};
//            //获取有关类型加载的JMX接口
//            ClassLoadingMXBean loadingBean = ManagementFactory.getClassLoadingMXBean();
//            //用于缓存类加载器
//            List<ClassLoader> classLoaders = new ArrayList<ClassLoader>();
//            while (true) {
//                //加载类型并缓存类加载器实例
//                ClassLoader classLoader = new URLClassLoader(urls);
//                classLoaders.add(classLoader);
//                //显示数量信息（共加载过的类型数目，当前还有效的类型数目，已经被卸载的类型数目）
//                System.out.println("total: " + loadingBean.getTotalLoadedClassCount());
//                System.out.println("active: " + loadingBean.getLoadedClassCount());
//                System.out.println("unloaded: " + loadingBean.getUnloadedClassCount());
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        String str = "base";
        while (true) {
            ArrayList<String> list = new ArrayList<String>();
            int i = 0;

            while (true) {
                list.add(String.valueOf(str + (i++)).intern());
            }
        }
    }
}
